<layout name='../Layout/frame_main' />
<body>
	<style type="text/css">
	.cn_val {color:blue;font-size: 16px;}
	.cn_name {font-family: "Helvetica Neue",Helvetica,Arial,"Microsoft Yahei UI","Microsoft YaHei",SimHei,"宋体",simsun,sans-serif;font-size: 16px;display:-moz-inline-box;display:inline-block;
width:70px; }
	</style>
	<script type="text/javascript">
	$(function(){
		$('form').submit(function(){
			var f=$(this)[0];
      if(f.adm_name.value=='')
      {
        alert('用户名不能为空！');
        return false;
      }
      if(f.adm_oldpass.value!='')
      {
        if(f.adm_pass[0].value=='' || f.adm_pass[1].value=='')
        {
          alert('若想更改密码，新密码不能为空！或者旧密码不填写且新密码也不填写！');
          return false;
        }
      }
      if(f.adm_pass[0].value!='' || f.adm_pass[1].value!='')
      {
        if(f.adm_oldpass.value=='')
        {
        alert('修改密码需要验证旧密码，请填写旧密码！');
        return false;
        }
      }
      if(f.adm_pass[0].value!=f.adm_pass[1].value)
      {
        alert('两次密码输入不一致，请重新输入！');
        return false;
      }
		});
	})
	</script>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<div class="page-header">
				<h2>
					用户列表
					<small>共{$count}条数据</small><br/>
<small><a data-toggle="modal" class="btn btn-small btn-primary" href="#myAdd">添加用户</a></small> 
				</h2>

			</div>
			<?php 
			if(count($list)==0)
			{
				echo '<h4>暂时没有数据</h4>';
			}
			else
			{
			?>
			<table class="table table-bordered table-hover table-condensed">
				<thead>
					<tr>
						<th>
							编号
						</th>
						<th>
							名称
						</th>
						<th>
							角色
						</th>
						<th>
							上次登录时间
						</th>
						<th>
							删除
						</th>

					</tr>
				</thead>
				<tbody>
					<volist name="list" id="vo">
					<tr >
						<td>
							{$vo.adm_id}
						</td>
						<td>
							{$vo.adm_realname}
						</td>
						<td>
							{$vo.rol_name}
						</td>
						<td>
							{$vo.adm_time}
						</td>
						<td>
						<a data-toggle="modal" class="btn btn-primary" role="button" href="#myEdit{$vo.adm_id}"><?php  if(is_com_role($vo["adm_role"])) echo "查看";else echo "修改"; ?></a>

						<a data-toggle="modal" class='btn btn-danger <?php if(is_com_role($vo["adm_role"]))echo "disabled"; ?>' role="button" href="#myModal{$vo.adm_id}">删除</a>

						</td>


						<form id="formedit{$vo.adm_id}" action="__URL__/ada/adm_id/{$vo.adm_id}" method='post'>
							  <div id="myEdit{$vo.adm_id}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								    <div class="modal-header">
								      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								      <h3 id="myModalLabel">信息详情</h3>
								    </div>
								    <div class="modal-body">
									    <div class="container-fluid">
											<div class="row-fluid">
												<div class="span12">
													<div class="row-fluid">
	<div class="span8">
		<input type="hidden" name="adm_id"  value='{$vo.adm_id}' />
		<span class='cn_name'>登陆角色</span><span class='cn_val'>
		<select name="adm_role" id="adm_role" <?php if(is_com_role($vo["adm_role"])) echo 'disabled'; ?> >
        <option value="0" >请选择角色</option>
		<volist name="role_type" id="r">

		<option value="{$r.rol_id}" <eq name="vo.adm_role" value="$r.rol_id" >selected</eq> />{$r.rol_name}</option>
		</volist>
        </select>
		</span><br/>	

		<span class='cn_name' >登陆名称&nbsp; </span><span class='cn_val'><input type="text" name="adm_name" <?php if(is_com_role($vo["adm_role"])) echo 'disabled'; ?>  value='{$vo.adm_name}' /></span><br/>

		<span class='cn_name'>真实名称&nbsp; </span><span class='cn_val'><input type="text" name="adm_realname" <?php if(is_com_role($vo["adm_role"])) echo 'disabled'; ?> value='{$vo.adm_realname}' />
		</span><br/>
<?php 
	if(!is_com_role($vo["adm_role"]))
	{
 ?>
		<span class='cn_name'>原始密码&nbsp; </span><span class='cn_val'><input type="password" name="adm_oldpass" value='' /></span><br/>
		<span class='cn_name'>新&nbsp;&nbsp;密&nbsp;&nbsp;码&nbsp; </span><span class='cn_val'><input type="password" name="adm_pass" value='' /></span><br/>

		<span class='cn_name'>确认密码&nbsp; </span><span class='cn_val'><input type="password" name="adm_pass" value='' /></span><br/>
<?php }?>

	</div>
														<div class="span4">
															<?php 
															if(!is_com_role($vo["adm_role"]))
															{
														 	?>
															<h3>注意：</h3>
															如果修改密码，必须填写原始密码！
															<?php }?>
														</div>
													</div>
												</div>
											</div>
										</div>
								    </div>
								    <div class="modal-footer">
								      <button class="btn" data-dismiss="modal" aria-hidden="true" id="clbtn{$vo.adm_id}">关闭</button>
								     <?php 	if(!is_com_role($vo["adm_role"])){ ?> 
								      <button class="btn btn-primary" type="submit">确认</button>
								      <?php }?>
								    </div>
							  </div>
							</form>

							<form id="form{$vo.adm_id}" action="__URL__/del/adm_id/{$vo.adm_id}" method='get'>
							  <div id="myModal{$vo.adm_id}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
							    <div class="modal-header">
							      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							      <h3 id="myModalLabel">系统 <?php if(!is_com_role($vo["adm_role"])) echo "确认";else echo "提示"; ?></h3>
							    </div>
							    <div class="modal-body">
							    	
							      <p><?php  if(!is_com_role($vo["adm_role"])) echo "确定要删除序号为【".$vo["adm_id"]."】，姓名为【".$vo["adm_realname"]."】 的账号吗？数据删除将导致无法恢复！点击【关闭】退出继续操作，点击【确认删除】进行删除数据操作。";
							      else echo "权限不足，无法删除！";
							  		?>
							  	</p>
							    </div>
							    <div class="modal-footer">
							      <button class="btn" data-dismiss="modal" aria-hidden="true" id="clbtn{$vo.adm_id}">关闭</button>
							      <?php  if(!is_com_role($vo["adm_role"])) echo '<button class="btn btn-danger" type="submit">确认删除</button>';
							      ?>
							    </div>
							  </div>
							</form>
						
					</tr>
				</volist>
				</tbody>
			</table>
			<div class="pagination pagination-centered">
				<ul>
					<li>{$page}</li>
				</ul>
			</div>
			<?php } ?>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span12">
		</div>
	</div>
</div>
<form id="formadd" action="__URL__/ada" method='post'>
							  <div id="myAdd" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								    <div class="modal-header">
								      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								      <h3 id="myModalLabel">添加用户</h3>
								    </div>
								    <div class="modal-body">
									    <div class="container-fluid">
											<div class="row-fluid">
												<div class="span12">
													<div class="row-fluid">
	<div class="span8">
		<span class='cn_name'>登陆角色</span><span class='cn_val'>
		<select name="adm_role" id="adm_role" >
        <option value="0" >请选择角色</option>
		<volist name="role_type" id="r">
		<option value="{$r.rol_id}" />{$r.rol_name}</option>
		</volist>
        </select>
		</span><br/>	

		<span class='cn_name'>登陆名称&nbsp; </span><span class='cn_val'><input type="text" name="adm_name"  value='' /></span><br/>

		<span class='cn_name'>真实名称&nbsp; </span><span class='cn_val'><input type="text" name="adm_realname" value='' />
		</span><br/>
		<span class='cn_name'>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码&nbsp; </span><span class='cn_val'><input type="password" name="adm_pass" value='' /></span><br/>

		<span class='cn_name'>确认密码&nbsp; </span><span class='cn_val'><input type="password" name="adm_pass" value='' /></span><br/>

	</div>
													</div>
												</div>
											</div>
										</div>
								    </div>
								    <div class="modal-footer">
								      <button class="btn" data-dismiss="modal" aria-hidden="true" id="clbtn">关闭</button>
								      <button class="btn btn-primary" type="submit">确认</button>
								    </div>
							  </div>
							</form>
</body>
<script type="text/javascript">
$(function(){
	$('.btn.btn-primary.see').click(function(){
		GoToUrl($.trim($(this).parent().parent().children(':first').html()));
	});
})
function GoToUrl(id)
{
	location.href="__URL__/newp/pro_id/"+id;
}
</script>
